package semaphores;

/**
 * The class synchronizes the reading and the writing actions.
 *
 * @author Manujlov Maxim
 */
public interface ISmartSemaphore {
  /**
   * The function must turn the semaphore down
   */
  public void down();

  /**
   * The function must turn the semaphore up
   */
  public void up();

  /**
   * The function must turn the semaphore down and start an exclusive session
   */
  public void exclusiveDown();

  /**
   * The function must turn the semaphore up and finish an exclusive session
   */
  public void exclusiveUp();

  /**
   * The function must execute a reading action
   *
   * @param r action
   */
  public void runReadAction(Runnable r);

  /**
   * The function must execute a writing action
   *
   * @param r action
   */
  public void runWriteAction(Runnable r);
}